using UnityEngine;
using System.Collections;

public class PlayerMovement : MonoBehaviour 
{
	public float speed;
	// Use this for initialization
	void Start () 
	{
	
	}
	
	// Update is called once per frame
	void Update () 
	{
		float x_direction = Input.GetAxis("Horizontal"); //Variable for the X direction
		float y_direction = Input.GetAxis("Vertical"); //Variable for the Y direction
		
		Vector3 direction = new Vector3(x_direction, y_direction, 0); //Creates a variable for the movement direction
		
		if(direction.magnitude > 1)
			direction.Normalize();
		
		Debug.Log(direction.magnitude.ToString());
		
		direction*=Time.deltaTime * speed;
		
		transform.Translate(direction); //Applies the movement
		
		float xClamped = Mathf.Clamp(transform.position.x, -6.9f, 6.9f);
		float yClamped = Mathf.Clamp(transform.position.y, -4.4f, 0.0f); 
				
		transform.position = new Vector3(xClamped, yClamped, 0.0f); //Applies the movement
		
	}
}
